home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE02 / TPACK / TPACK.ZIP / DEBUGCTL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-06-01  |  5.0 KB  |  158 lines

  1. {------------------------------------------------------------------------------}
  2. {UNREGISTERED VERSION (6/1/95) PLEASE REDISTRIBUTE IN tPACK.ZIP!
  3.  This revision does not contain everything, nor are the exciting
  4.  DataSetReporter and ExtendedMenu[Item] components included.
  5.  Use SWREG#5906 to receive these, icons and a help file for $130.
  6.  You must register when using this code in a business application!
  7.  You'll receive a license to use this code in up to 50 copies of
  8.  any app you write. In turn you will get responsive e-mail
  9.  tech support and enhancements till I run out of registrations
  10.  or suggestions. Meanwhile.. enjoy the code. Bye! I'll make more.
  11.  {(C)'1995 Michael/Ax-Systems, 71560,1754@Compuserve.com}
  12. {------------------------------------------------------------------------------}
  13.  
  14. unit Debugctl;
  15.  
  16. interface
  17.  
  18. uses
  19.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  20.   Forms, Dialogs, StdCtrls, Buttons, Toolbar, ExtCtrls
  21. , Debug
  22. , UserInfo;
  23.  
  24. type
  25.   TDebugControl= class(TDialogShell)
  26.   private
  27.     {uses vars global to this unit}
  28.   protected
  29.     function GetState:TDebugExtendedComponentState;
  30.     procedure SetState(Value:TDebugExtendedComponentState);
  31.     function GetFlags:TDebugExtendedComponentFlags;
  32.     procedure SetFlags(Value:TDebugExtendedComponentFlags);
  33.     function GetTest:Boolean; override;
  34.     procedure SetTest(Value:Boolean); override;
  35.     function GetEnabled:Boolean;
  36.     procedure SetEnabled(Value:Boolean);
  37.   public
  38.     constructor Create(aOwner:TComponent); Override;
  39.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  40.     destructor Destroy; Override;
  41.     procedure Loaded; Override;
  42.   published
  43.     property Options: TDebugExtendedComponentFlags read GetFlags write SetFlags;
  44.     property Enabled: Boolean read GetEnabled write SetEnabled stored false;
  45.     property State: TDebugExtendedComponentState read GetState write SetState stored false;
  46.     end;
  47.  
  48. implementation
  49.  
  50. {-----------------------------------------------------------------------------------------}
  51. { TDebugControl                                                                            }
  52. {-----------------------------------------------------------------------------------------}
  53.  
  54. constructor TDebugControl.Create(aOwner:TComponent);
  55. begin
  56.   inherited Create(aOwner);
  57.   DebugState:=DebugState-[decDestroying];
  58.   Options:= DebugFlags;
  59.   if (decCreate in DebugFlags) then
  60.     DebugLog(nil,'Create '+ClassName);
  61. end;
  62.  
  63. destructor TDebugControl.Destroy;
  64. begin
  65.   if (decDestroy in DebugFlags) then
  66.     DebugLog(nil,'Destroy '+ClassName);
  67.   DebugState:=DebugState+[decDestroying]-[decActive];
  68.   Options:=[];
  69.   {DebugDlg.Free;
  70.   DebugDlg:=nil;}
  71.   inherited Destroy;
  72. end;
  73.  
  74. procedure TDebugControl.Loaded;
  75. begin
  76.   if (decLoaded in DebugFlags) then
  77.     DebugLog(nil,'Loaded '+ClassName);
  78.   inherited Loaded;
  79.   ComponentIndex:=0;        {makes itself first component.}
  80. end;
  81.  
  82. procedure TDebugControl.Notification(AComponent: TComponent; Operation: TOperation);
  83. begin
  84.   inherited Notification(AComponent, Operation);
  85.   if aComponent<>nil then begin
  86.     if (aComponent is TDebugControl) and (Operation = opRemove) then
  87.       DebugState:=DebugState-[decDestroying]+[decActive];
  88.     if (([decInsert, decRemove]*DebugFlags)<>[]) then
  89.       if (Operation = opRemove) and (decRemove in DebugFlags) then
  90.         DebugLog(nil,'Remove '+AComponent.Name+'('+AComponent.ClassName+')')
  91.       else
  92.         if (Operation = opInsert) and (decInsert in DebugFlags) then
  93.           DebugLog(nil,'Insert '+AComponent.Name+'('+AComponent.ClassName+')');
  94.     end;
  95. end;
  96.  
  97. {}
  98.  
  99. function TDebugControl.GetState:TDebugExtendedComponentState;
  100. begin
  101.   Result:=DebugState;
  102. end;
  103.  
  104. procedure TDebugControl.SetState(Value:TDebugExtendedComponentState);
  105. begin {DebugState:=Value;} {read only}
  106. end;
  107.  
  108. {}
  109.  
  110. function TDebugControl.GetEnabled:Boolean;
  111. begin
  112.   Result:=decEnabled in DebugFlags;
  113. end;
  114.  
  115. procedure TDebugControl.SetEnabled(Value:Boolean);
  116. begin
  117.   if Value and (not GetEnabled) then
  118.     AdjustDebugFlags(DebugFlags+[decEnabled])
  119.   else
  120.     if (not Value) and GetEnabled then
  121.       AdjustDebugFlags(DebugFlags-[decEnabled]);
  122. end;
  123.  
  124. {}
  125.  
  126. function TDebugControl.GetFlags:TDebugExtendedComponentFlags;
  127. begin
  128.   Result:=DebugFlags;
  129. end;
  130.  
  131. procedure TDebugControl.SetFlags(Value:TDebugExtendedComponentFlags);
  132. begin
  133.   if (csLoading in ComponentState) then
  134.     DebugFlags:=Value
  135.   else
  136.     Debug.AdjustDebugFlags(Value); {adjusts state and changes flags}
  137. end;
  138.  
  139. {}
  140.  
  141. {-----------------------------------------------------------------------------------------}
  142. { DESIGN TIME TEST PROCS                                                                  }
  143. {-----------------------------------------------------------------------------------------}
  144.  
  145. procedure TDebugControl.SetTest(Value:Boolean);
  146. begin
  147.   DebugLog(nil,'Test '+ClassName);
  148. end;
  149.  
  150. function TDebugControl.GetTest:Boolean;
  151. begin
  152.   Result:= decActive in DebugState;
  153. end;
  154.  
  155. end.
  156.  
  157.  
  158.